<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="js/vue.min.js"></script>
<style type="text/css">
.red{color:red;}
.orange{color:orange;}
.yellow{color:yellow;}
</style>
</head>
<body>
<div id="myApp">
<h3>filters过滤器</h3>
{{message}}<br>
{{ message | capitalize }}(首字母大写)
<h3>分数过滤器</h3>
<p v-for="x in score">
	{{x}} --- {{x | scoreFilter}}
</p>
<h3>参数过滤器</h3>
{{message | oneFilter('1','sum')}}
<div>
<br>
提示：<br>
1：{ { message | filterA | filterB } } 过滤器可以这样进行串联。<br>
2：{ { message | filterA('arg1', arg2) } }这里，message 是第一个参数，字符串 'arg1' 将传给过滤器作为第二个参数， arg2 表达式的值将被求值然后传给过滤器作为第三个参数。
</div>
</div>
<script type="text/javascript">
var myApp = new Vue({
	el:"#myApp",
	data:{
		message:'hello world!',
		score:[65,58,72,85],
		onOff:true,
	},
	filters:{
		capitalize: function (val) {
			if (!val) return ''
			val = val.toString();
			return val.charAt(0).toUpperCase() + val.slice(1);
		},
		scoreFilter:function(val){
			if(val<60){
				return "不及格";
			}else if((60<=val) && (val<70)){
				return "刚好及格";
			}else if((70<=val) && (val<80)){
				return "良好";
			}else if((80<=val) && (val<90)){
				return "优秀";
			}; 
		},
		oneFilter:function(val,one,two){
			console.log(val);
			console.log(one);
			console.log(two);
			return "你好!";
		}
	} 
});
</script>
</body>
</html>